package com.litchi.activity;

import com.lib.uil.ToastUtils;
import com.litchi.R;
import com.litchi.bean.FeedBack;

import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;

public class FeedBackActivity extends Activity implements OnClickListener {

	private EditText adviceEd, phoneEd;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_feedback);

		initView();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}

	public void initView() {
		findViewById(R.id.img_back).setOnClickListener(this);
		findViewById(R.id.send).setOnClickListener(this);
		adviceEd=(EditText)findViewById(R.id.advice);
		phoneEd=(EditText)findViewById(R.id.phone);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.img_back:
			finish();
			break;
		case R.id.send:
			sendAdvice();
			break;
		default:
			break;
		}
	}
	
	
	
	public void sendAdvice(){
		String advice=adviceEd.getText().toString().trim();
		String phone=phoneEd.getText().toString().trim();

		if (!TextUtils.isEmpty(advice)&&!TextUtils.isEmpty(phone)) {
			FeedBack mFeedBack=new FeedBack();
			mFeedBack.setAdvice(advice);
			mFeedBack.setPhone(phone);
			mFeedBack.save(this);
			ToastUtils.showToast(this, "反馈意见已发送");
			finish();
		}else {
			ToastUtils.showToast(this, "建议或联系方式不能为空！");
		}
	}
}
